<script setup>
import { useRoute } from "vue-router";
import TabBar from "./components/TabBar.vue";
import { ref } from "vue";
import router from "./router";

// 让导航栏标题能根据页面自动变化
const route = useRoute();

// 返回按钮方法
const onClickLeft = function() {
  //如果历史记录有上一页存在，则返回上一页，否则返回上一页
  if( history.length > 1) {
    route.back();
  } else {
    router.push({ name: 'home' })
  }
}

//是否显示底部导航栏
const isShowTabber = ref(true);

//监听路由当中

</script>

<template>
  <van-nav-bar
    :title="$route.meta.title"
    :left-arrow = "$route.meta.isShowBack"
    @click-left="onClickLeft"
    fixed
    placeholder
  />
  <RouterView />
  <!-- 底部导航栏 -->
  <TabBar />
</template>

<style lang="scss" scoped>

</style>
